#region Copyright

// Partial Copyright (c) LogoUI Software Solutions LTD
// Author: Vladislav Spivak
// This source file is the part of LogoFX Framework http://logofx.codeplex.com
// See accompanying licences and credits.

#endregion


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
#if WinRT
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using CultureInfo = System.String;
#else
using System.Windows.Data;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
#endif

namespace LogoFX.Infra
{
    public class MulConstantConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
                parameter = 1;
            Decimal dec = System.Convert.ToDecimal(value);
            if (dec < 0)
            {
                return Double.NaN;
            }
            else
            {
                return dec*System.Convert.ToDecimal(parameter);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
                parameter = 1;
            return System.Convert.ToDecimal(value) / System.Convert.ToDecimal(parameter);
        }
    }
}
